<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.11.
   家居公司发布点评($$)*/

!defined('Q_PATH') && exit;

class Addcomment_C_Controller extends InitController{

	public function index(){
		$arrJiajucompany=$this->_oParent->_arrJiajucompany;
		
		// 提交点评
		if($this->isPost()){
			if($GLOBALS['___login___']===FALSE){
				$this->E('你需要登录后才能够发布点评！');
			}

			// 判断是否已经点评过了
			$oTryComment=JiajucompanycommentModel::F("user_id=? AND ".CURRENT_TIMESTAMP."-create_dateline<2592000 AND jiajucompany_id=?",$GLOBALS['___login___']['user_id'],$arrJiajucompany['jiajucompany_id'])->getOne();
			if(!empty($oTryComment['jiajucompanycomment_id'])){
				$this->E('你本月已经发布过点评，请换过帐号试试！');
			}

			$oComment=new JiajucompanycommentModel();
			
			// 站点属性
			$oComment->site_id=$arrJiajucompany['site_id'];
			$oComment->jiajucompany_id=$arrJiajucompany['jiajucompany_id'];

			$oComment->jiajucompanycomment_status=0;
			$oComment->save();
			if($oComment->isError()){
				$this->E($oComment->getErrorMessage());
			}else{
				Jiaju_Credit::RUN($this->_oParent->_arrJiajucompany['jiajucompany_id'],$oComment->jiajucompanycomment_id,$oComment->create_dateline,1,0,'','jiajucompanycomment');
				
				$this->A($oComment->toArray(),'点评提交成功，请等待审核通过！',1);
			}
		}

		Core_Extend::getSeo($this,array(
			'title'=>"{$arrJiajucompany['jiajucompany_fullname']}发布点评",
			'keywords'=>"{$arrJiajucompany['jiajucompany_fullname']},发布点评",
			'description'=>$GLOBALS['_option_']['site_name']."为您提供{$arrJiajucompany['jiajucompany_fullname']}在线发布点评服务，是您与{$arrJiajucompany['jiajucompany_fullname']}进行装修交易后评论商家服务态度的最佳方式。",
		));
		
		$this->display(Jiaju_Extend::getTemplate($arrJiajucompany));
	}

}
